// ==========================================================================
// GFast自动生成dao internal操作代码。
// 生成日期：2024-11-13 17:44:14
// 生成路径: internal/app/system/dao/internal/runners.go
// 生成人：gfast
// desc:跑手管理
// company:云南奇讯科技有限公司
// ==========================================================================

package internal

import (
	"context"

	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/frame/g"
)

// RunnersDao is the manager for logic model data accessing and custom defined data operations functions management.
type RunnersDao struct {
	table   string         // Table is the underlying table name of the DAO.
	group   string         // Group is the database configuration group name of current DAO.
	columns RunnersColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// RunnersColumns defines and stores column names for table runners.
type RunnersColumns struct {
	Id             string // 跑手表
	Userid         string // 用户id
	SchoolId       string // 关联的学校id 在认证跑手的时候同步user表的schoolid过来
	Money          string // 佣金
	Score          string // 信誉分 >50才可以成为跑手
	StCardFrontImg string // 学生证正面照片
	StCardBackImg  string // 学生证反面照片
	IsConfirm      string // 是否审核通过 1通过 只有1才能接单 2拒绝 0待审核
	IsBan          string // 是否被封禁 1是 0否
	IsDel          string // 是否删除 0：未删除 1：已删除
	CreatedAt      string //
	UpdatedAt      string //
}

var runnersColumns = RunnersColumns{
	Id:             "id",
	Userid:         "userid",
	SchoolId:       "school_id",
	Money:          "money",
	Score:          "score",
	StCardFrontImg: "st_card_front_img",
	StCardBackImg:  "st_card_back_img",
	IsConfirm:      "is_confirm",
	IsBan:          "is_ban",
	IsDel:          "is_del",
	CreatedAt:      "created_at",
	UpdatedAt:      "updated_at",
}

// NewRunnersDao creates and returns a new DAO object for table data access.
func NewRunnersDao() *RunnersDao {
	return &RunnersDao{
		group:   "default",
		table:   "runners",
		columns: runnersColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *RunnersDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of current dao.
func (dao *RunnersDao) Table() string {
	return dao.table
}

// Columns returns all column names of current dao.
func (dao *RunnersDao) Columns() RunnersColumns {
	return dao.columns
}

// Group returns the configuration group name of database of current dao.
func (dao *RunnersDao) Group() string {
	return dao.group
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *RunnersDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *RunnersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
